# Default Dockerfile

FROM hyperf/hyperf:7.4-alpine-v3.12-swoole

##
# ---------- env settings ----------
##
# --build-arg timezone=Asia/Shanghai
ARG timezone

ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \
    COMPOSER_VERSION=1.8.6

# update
RUN set -ex \
    && apk update \
    # install composer 很慢
    #&& wget -nv -O /usr/local/bin/composer https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \
    #替换 composer
    && php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"  \
    && php composer-setup.php --install-dir=/usr/local/bin --filename=composer  \
    && php -r "unlink('composer-setup.php');"  \
    && chmod u+x /usr/local/bin/composer \
    #hbw 自定义composer镜像地址
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer \ 
    # show php version and extensions
    && php -v \
    && php -m \
    #  ---------- some config ----------
    && cd /etc/php7 \
    # - config PHP
    && { \
        echo "upload_max_filesize=128M"; \
        echo "post_max_size=128M"; \
        echo "memory_limit=1G"; \
        echo "date.timezone=${TIMEZONE}"; \
    } | tee conf.d/99-overrides.ini \
    # - config timezone
    && ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
    && echo "${TIMEZONE}" > /etc/timezone \
    # ---------- clear works ----------
    && rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
    && echo -e "\033[42;37m Build Completed :).\033[0m\n"

#COPY ./backend /opt/www 宿主机没有

WORKDIR /opt/www

 #RUN composer install --no-dev -o //跟环境有关

EXPOSE 9501

#ENTRYPOINT ["php", "/opt/www/bin/hyperf.php", "start"]
CMD ["php", "/opt/www/bin/hyperf.php", "start"]